package xy.donate.android.ui.activity

import android.annotation.SuppressLint
import androidx.room.Room
import kotlinx.android.synthetic.main.activity_order_detail.*
import xy.donate.android.R
import xy.donate.android.common.MyActivity
import xy.donate.android.db.OrderDao
import xy.donate.android.db.OrderDb

class OrderDetailActivity : MyActivity() {
    private var orderNo: String = ""
    override fun getLayoutId(): Int {
        return R.layout.activity_order_detail
    }

    override fun initView() {
        orderNo = intent.getStringExtra("OrderNo") as String
        ll_commit_order.setOnClickListener {
            finish()
        }
    }

    @SuppressLint("SetTextI18n")
    override fun initData() {
        val dao: OrderDao = Room.databaseBuilder(this, OrderDb::class.java, "orderDB")
                .allowMainThreadQueries()
                .build().orderDao()
        val bean = dao.getOrderDetail(orderNo)
        if (bean != null) {
            tv_name_phone.text = "${bean.address.realName}   ${bean.address.phoneNum}"
            tv_order_address.text = bean.address.detailAddress
            tv_time.text = bean.time
            if (bean.bz.isNullOrEmpty()) {
                tv_order_remark.text = "暂无备注"
            } else {
                tv_order_remark.text = bean.bz
            }
            tv_order_no.text = "订单编号:${bean.orderNo}"
            tv_order_time.text = bean.orderTime

        }
    }
}